//
//  FourSeasonMenuViewController.m
//  ProjectA
//
//  Created by dlios on 15/3/5.
//  Copyright (c) 2015年 dlios. All rights reserved.
//

#import "FourSeasonMenuViewController.h"

@interface FourSeasonMenuViewController ()

@end

@implementation FourSeasonMenuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     //背景图片
    UIImage *image = [UIImage imageNamed:@"card.png"];
    self.imageV = [[UIImageView alloc] initWithImage:image];
    self.imageV.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    self.indexLabel.text = @"春天专属";
    [self.view addSubview:self.imageV];
    self.sliderImageView.userInteractionEnabled = YES;
    //小心心
   UIImage *heartImage = [UIImage imageNamed:@"0.png"];
   self.imageview = [[UIImageView alloc] initWithImage:heartImage];
    self.imageview.frame = CGRectMake(self.sliderImageView.frame.origin.x - 30, self.sliderImageView.frame.origin.y - 30, 90, 25);
    //底部小心心
    UIImage *heartfootImage = [UIImage imageNamed:@"1.png"];
    self.footimageview = [[UIImageView alloc] initWithImage:heartfootImage];
    self.footimageview.frame = CGRectMake(self.sliderImageView.frame.origin.x + self.sliderImageView.frame.size.width - 30,self.sliderImageView.frame.origin.y + self.sliderImageView.frame.size.height + 23, 90, 25);
    [self.imageV addSubview:self.footimageview];
    [self.imageV addSubview:self.imageview];
    self.navigationItem.title = @"上得厅堂";
    
    //----------------------第三方炫图-------------------------//
    
    //签订第三方协议
    self.sliderImageView.delegate = self;
    //放第三方的效果图片
    for (int i = 0; i < 4; i++) {
        NSString *imageName = [NSString stringWithFormat:@"%d", i];
        UIImage *image = [UIImage imageNamed:imageName];
        [self.sliderImageView addImage:image];
    
    }
    
    //第三方UIView
    [self.sliderImageView setImageShadowsWtihDirectionX:2 Y:2 Alpha:0.7];
    [self.sliderImageView reLoadUIview];
    //------------------------------------------------------//
    self.imageV.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    [self.view addSubview:self.imageV];
    
    //头部小心心动图
    NSMutableArray *array = [NSMutableArray array];
    for (int i = 1; i < 17; i++) {
        NSString *name = [NSString stringWithFormat:@"go%d", i];
        NSString *filepath = [[NSBundle mainBundle] pathForResource:name ofType:@"tiff"];
        UIImage *image = [UIImage imageWithContentsOfFile:filepath];
        [array addObject:image];
    }
    
    self.imageview.animationImages = array;
    self.imageview.animationDuration = 2.0;
    self.imageview.animationRepeatCount = 0;
    [self.imageview startAnimating];
    
    //底部小心心
    NSMutableArray *footarray = [NSMutableArray array];
    for (int i = 1; i < 17; i++) {
        NSString *footname = [NSString stringWithFormat:@"go%d", i];
        NSString *footfilepath = [[NSBundle mainBundle] pathForResource:footname ofType:@"tiff"];
        UIImage *image = [UIImage imageWithContentsOfFile:footfilepath];
        [footarray addObject:image];
    }

    self.footimageview.animationImages = footarray;
    self.footimageview.animationDuration = 2.0;
    self.footimageview.animationRepeatCount = 0;
    [self.footimageview startAnimating];
    
    // Do any additional setup after loading the view.
}

-(void)SlideImageViewDidClickWithIndex:(int)index
{
    if (index == 0) {
        SpringViewController *springV = [[SpringViewController alloc] init];
        springV.navigationItem.title = @"春天专属";
        [self.navigationController pushViewController:springV animated:YES];
    }
    if (index == 1) {
        SummerViewController *summerV = [[SummerViewController alloc] init];
        summerV.navigationItem.title = @"夏天独享";
        [self.navigationController pushViewController:summerV animated:YES];
    }
    if (index == 2) {
        AutumnViewController *autumnV = [[AutumnViewController alloc] init];
        autumnV.navigationItem.title = @"秋天美味";
        [self.navigationController pushViewController:autumnV animated:YES];
    }
    if (index == 3) {
        WinterViewController *winterV = [[WinterViewController alloc] init];
        winterV.navigationItem.title = @"冬天回味";
        [self.navigationController pushViewController:winterV animated:YES];
    }
    
}


-(id)init
{
    
    self = [super init];
    if (self) {
        //第三方适配
        CGFloat width = [UIScreen mainScreen].bounds.size.width;
        CGFloat height = [UIScreen mainScreen].bounds.size.height;
        CGRect rect = {{50,130},{width-130,height-320}};
        self.sliderImageView = [[SlideImageView alloc] initWithFrame:rect ZMarginValue:6 XMarginValue:10 AngleValue:0.3 Alpha:1000];
        self.sliderImageView.borderColor = [UIColor whiteColor];
        self.sliderImageView.delegate = self;
        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
        [self.view bringSubviewToFront:self.clickLabel];
       
        
    }
    return self;
}



- (void)loadView
{
    [super loadView];
    [self.view addSubview:self.sliderImageView];
     self.indexLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, self.sliderImageView.frame.origin.y + self.sliderImageView.frame.size.height + 10, 200, 35)];
    self.indexLabel.font = [UIFont systemFontOfSize:20.f];
    self.indexLabel.textColor = [UIColor whiteColor];
    [self.view addSubview:self.indexLabel];
    
}



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)SlideImageViewDidEndScorllWithIndex:(int)index
{
       if (index == 0) {
           
        self.indexLabel.text = @"春天专属";
        self.indexLabel.textColor = [UIColor whiteColor];
        UIImage *image = [UIImage imageNamed:@"card.png"];
        self.imageV = [[UIImageView alloc] initWithImage:image];
        self.imageV.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
        [self.view addSubview:self.imageV];
        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
           //头部小心心动图 动图只能用路径获取
           NSMutableArray *heartArray = [NSMutableArray array];
           for (int i = 1; i < 17; i++) {
               NSString *name = [NSString stringWithFormat:@"go%d", i];
               NSString *filepath = [[NSBundle mainBundle] pathForResource:name ofType:@"tiff"];
               UIImage *firstHeart = [UIImage imageWithContentsOfFile:filepath];
               [heartArray addObject:firstHeart];
           
           
           
           }
           
           
           
           UIImageView *heartImageView = [[UIImageView alloc] initWithFrame: CGRectMake(self.sliderImageView.frame.origin.x - 30, self.sliderImageView.frame.origin.y - 30, 90, 25)];
           heartImageView.animationImages = heartArray;
           heartImageView.animationDuration = 2.5;
           heartImageView.animationRepeatCount = 0;
           [heartImageView startAnimating];
           [self.view bringSubviewToFront:self.imageV];
           [self.view addSubview:heartImageView];
           [self.view bringSubviewToFront:self.sliderImageView];
           [self.view bringSubviewToFront:self.indexLabel];
           
    
    }else if (index == 1){
        self.indexLabel.text = @"夏天独享";
        self.indexLabel.textColor = [UIColor purpleColor];
        UIImage *image = [UIImage imageNamed:@"summer.jpg"];
        self.imageV = [[UIImageView alloc] initWithImage:image];
        self.imageV.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
        [self.view addSubview:self.imageV];
        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
        
    }else if (index == 2){
        self.indexLabel.text = @"秋天美味";
        self.indexLabel.textColor = [UIColor whiteColor];
        UIImage *image = [UIImage imageNamed:@"autumn.png"];
        self.imageV = [[UIImageView alloc] initWithImage:image];
        self.imageV.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
        [self.view addSubview:self.imageV];
        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
        
    }else if (index == 3){
        self.indexLabel.text = @"冬天回味";
        self.indexLabel.textColor = [UIColor cyanColor];
        //----------------动图----------------------------------//
        NSMutableArray *array = [NSMutableArray array];
        for (int i = 1; i < 7; i++) {
            NSString *name = [NSString stringWithFormat:@"winter2－%d", i];
            NSString *filepath = [[NSBundle mainBundle] pathForResource:name ofType:@"tiff"];
            UIImage *image = [UIImage imageWithContentsOfFile:filepath];
            [array addObject:image];
            
        }
        self.imageV.animationImages = array;
        self.imageV.animationDuration = 2;
        self.imageV.animationRepeatCount = 0;
        [self.imageV startAnimating];
        //--------------------------------------------------//
        self.imageV.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
        [self.view addSubview:self.imageV];
        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
        
    }
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
